extends Node2D


class_name HandGroup

static var Inst: HandGroup;

func _ready() -> void:
	Inst = self

var cards: Array


func updateView():
	
	var size = cards.size()
	
	for i in range(size):
		cards[i].position = getCardPosition(i, size)
	

func getCardPosition(i, size):
	
	var width = 152
	var sizeWidth = width * size
	var startX = 960 - sizeWidth /2 + width /2
	
	var x = startX + i * width
		
	return Vector2(x, 955.0)


func addCard(card, isReparent=false):
	cards.append(card)
	
	if isReparent:
		card.reparent(self)
	else:	
		add_child(card)
	
	updateView()
	
func removeCard(card):
	var index = cards.find(card)
	if index != -1:
		cards.remove_at(index)
		updateView()
		
